<?php
	session_start();

	include('includes/db_connect.php');

	switch ($_GET['act']) {
		case 1:
			$sql = "SELECT * FROM users WHERE username = '".$_POST['username']."' AND password = '".$_POST['password']."' LIMIT 1";
			$query = mysql_query($sql);
			$results_length = mysql_num_rows($query);
			if ($results_length > 0) {
				$query = mysql_query($sql);
				$data = mysql_fetch_array($query);
				$_SESSION['is_logged_in'] = true;
				$_SESSION['username'] = $data['username'];
				$_SESSION['fullname'] = $data['fullname'];
				$_SESSION['user_type'] = $data['user_type'];
				$_SESSION['id'] = $data['id'];

				header('Location: index.php');
			} else {
				echo "Log In Attempt Failed.";
			}
			break;
		case 2:
			# code...
			session_destroy();
			header('Location: index.php');
			break;
	}


?>